import getApiData from "@/services/cpasRequest";

// 获取账套
export async function getAccountInfo(params: {
  dbname: string;
}) {
  try {
    const res = await getApiData("account.accountInfo.getDataList", params);
    if (res.ok) {
      return Promise.resolve({
        data: res.data,
        success: true,
      });
    }
    return Promise.resolve({
      data: res.data,
      success: false,
    });
  } catch (error) {
    return Promise.resolve({
      data: '接口getDataList,请求失败！',
      success: false,
    });
  }
}

export async function getQckmhdData(params: {
  dbname: string; data_ID: string | number; wcybxs?: boolean
}) {
  if (!params.dbname) return [];
  try {
    const res = await getApiData("account.ws.qckmhd", params);
    if (res.ok) {
      return Promise.resolve({
        data: res.data,
        success: true,
      });
    }
    return Promise.resolve({
      data: res.data,
      success: false,
    });
  } catch (error) {
    return Promise.resolve({
      data: '接口qckmhd,请求失败！',
      success: false,
    });
  }
}
// 获取 getQcbbhdData
export async function getQcbbhdData(params: {
  dbname: string; data_ID: string | number; wcybxs?: boolean
}) {
  if (!params.dbname) return [];
  try {
    const res: any = await getApiData("account.ws.qcbbhd", params);
    if (res.ok) {
      return Promise.resolve({
        data: res.data,
        success: true,
      });
    }
    return Promise.resolve({
      data: res.data,
      success: false,
    });
  } catch (error) {
    return Promise.resolve({
      data: '接口qcbbhd,请求失败！',
      success: false,
    });
  }
}

// 获取 getWstzfl
export async function getWstzfl(params: {
  dbname: string; Data_ID: number; itemName?: string
}) {
  if (!params.dbname) return [];
  try {
    const res: any = await getApiData("account.adjustingEntry.ws.tzfl", params);
    if (res.ok) {
      return Promise.resolve({
        data: res.data,
        success: true,
      });
    }
    return Promise.resolve({
      data: res.data,
      success: false,
    });
  } catch (error) {
    return Promise.resolve({
      data: '接口tzfl,请求失败！',
      success: false,
    });
  }
}
